
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>@service、@Controller、@Component，@Repository的区别 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>@service、@Controller、@Component，@Repository的区别 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">概念</div>
          <div class="card-question">在Spring框架中，`@Component`注解的作用是什么？它通常用于哪种类型的类？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">概念</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`@Component`是最通用的组件注解，用于将一个类标识为Spring管理的组件或Bean，并交由Spring容器进行管理。它通常用于普通的Java类，如工具类、辅助类等。</div>
          </div>
          <div class="card-source">来源: 文档中对 `@Component` 的描述部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Spring中的`@Service`、`@Controller`和`@Repository`注解之间有什么共同点？它们与`@Component`有何关系？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">它们的共同点是都能将类标识为Spring的Bean并交由容器管理。从源码可以看出，`@Service`、`@Controller`和`@Repository`都是`@Component`注解的特例（或派生），它们自身都被`@Component`元注解所标记。</div>
          </div>
          <div class="card-source">来源: 文档中对各个注解的描述及「源码展示」部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">既然`@Service`、`@Controller`等注解本质上都是`@Component`，为什么还要在开发中区分使用它们？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要区别在于语义。使用更具体的注解（如`@Service`用于业务层，`@Controller`用于控制层，`@Repository`用于数据访问层）可以更清晰地表示组件的用途和职责，从而提高代码的可读性和项目的结构清晰度。</div>
          </div>
          <div class="card-source">来源: 文档中对各个注解的描述以及结尾段落的总结</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Spring MVC应用中，哪个注解专门用于标识处理用户请求并返回视图或数据的控制器组件？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`@Controller`注解。它专门用于标识Spring MVC中的控制器，用于处理Web请求，并将请求映射到相应的方法上。</div>
          </div>
          <div class="card-source">来源: 文档中对 `@Controller` 的描述部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">哪个Spring注解专门用于标识数据访问层（DAO）的组件，以表明其负责与数据库等数据源进行交互？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`@Repository`注解。它用于标识数据访问层的组件，如DAO类，使用此注解可以更清晰地表示该类用于数据访问。</div>
          </div>
          <div class="card-source">来源: 文档中对 `@Repository` 的描述部分</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">当Spring容器启动时，它是如何利用`@Component`及其派生注解来管理这些类的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">这些注解是用于Spring的组件扫描机制的。当Spring容器启动时，它会自动扫描类路径下带有这些注解的类，然后将它们实例化为Bean，并放入Spring容器中，以便在其他组件中注入和使用。</div>
          </div>
          <div class="card-source">来源: 文档结尾段落的总结部分</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
